package com.xunfang.common.enumeration.impl;

import com.xunfang.common.enumeration.ResultCode;
/**
 * 枚举封装业务级别的状态码
 */
public enum BusinessCode implements ResultCode {

    LOGIN_SUCCESS(200, "登录成功，欢迎你："),
    TOKEN_NOT_EXISTS(401, "Token不存在"),  //401
    INVALID_TOKEN(402, "无效的Token"),
    USER_NOT_LOGGED(403, "用户未登录"),   //403
    //自定义的状态码
    INVALID_VERIFICATION(450, "验证码失效"),
    VERIFICATION_ERROR(451, "验证码错误"),
    USER_NOT_EXIST(452, "用户不存在"),
    PASSWORD_ERROR(453, "密码错误"),
    USER_FROZEN_ERROR(454, "账户被冻结"),
    INVALID_IP(455, "无效的IP地址"),
    SMS_SEND_ERROR(456, "短信验证码发送失败"),
    EMAIL_EXIST_ERROR(457, "邮箱已经被注册"),
    USER_IS_EXIST(458, "用户名已经存在"),
    MOBILE_IS_EXIST(459, "手机号码已经存在"),
    STORAGE_NOT_ENOUGH(460, "商品库存不足"),
    REPEAT_COMMIT(461, "请勿重复提交"),
    CART_IS_EMPTY(462, "购物车为空"),
    GET_LOCK_FAIL(463, "获取锁失败");

    private int code;
    private String message;

    BusinessCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 获取状态码
     */
    @Override
    public Integer getCode() {
        return this.code;
    }

    /**
     * 获取状态信息
     */
    @Override
    public String getMessage() {
        return this.message;
    }
}